﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using tracker.Models;
using tracker.Models.DTO;
using tracker.Models.BLL;
namespace tracker.Controllers
{
    public class HandlerGetUserInfoController : Controller
    {
        //
        // GET: /HandlerGetUserInfo/
        [CallAjaxFilter]
        public JsonStringResult Index(String UserID)
        {
            String result = "";
            EUserLogin user = null;
            List<ENTGroupUserInfo> list = new List<ENTGroupUserInfo>();
            if (!String.IsNullOrEmpty(UserID))
            {
                user = new EUserLoginBLL().getBySecurityCode(UserID);
                if (user != null)
                {
                    HandlerGetGroupInfoController.vAddToList(list, user);
                }
            }
            result = Utilities.getJsonString(list, "data:", 1);
            if (user != null)
            {
                result = result.Replace("\"AccountStatusExpression\":null", "\"AccountStatusExpression\":" + Utilities.getAccountStatus(user.Status));
                result = result.Replace("\"PermissionExpression\":null", "\"PermissionExpression\":" + Utilities.getPermission(user.UserGroupID));
            }
            return new JsonStringResult(result);
        }

    }
}
